#include "qmessageopt.h"

QMessageOpt::QMessageOpt(QObject *parent)
    : QObject{parent}
{

}

void QMessageOpt::AddUserContent(const QString& sContent)
{
    QJsonObject JUser;
    JUser["role"] = "user";
    JUser["content"] = sContent;
    m_messageArray.append(JUser);
}

void QMessageOpt::AddAssistantContent(const QString& sContent)
{
    QJsonObject JUser;
    JUser["role"] = "assistant";
    JUser["content"] = sContent;
    m_messageArray.append(JUser);
}

QByteArray& QMessageOpt::GetJsonStr()
{
    QJsonObject obj;
    obj["messages"] = m_messageArray;
    m_byteMessage = QJsonDocument(obj).toJson();
    return m_byteMessage;
}
